<script>
  import isStunAddressUp from "./utils";

  let server;

  async function handleClick() {
    isStunAddressUp(server, 5000)
      .then(function (result) {
        console.log(result);
        // `result` Should contain an object like this:
        //{
        //    "myIpAddress": "[::ffff:xxx.xxx.xx.xx]",
        //    "stun": "stun.ipfire.org:3478",
        //    "ipv6Supported": true,
        //    "errors": []
        //}
      })
      .catch(function (err) {
        // Something went wrong
        console.log(err);
      });
  }
</script>

<div>
  <div class="row">
    <input
      id="server-input"
      placeholder="Enter a server address..."
      bind:value={server}
    />
    <button on:click={handleClick}>Check </button>
  </div>
</div>
